 
package beaver.game;

import java.io.Serializable;


/**
 * This class will contain the information Pertaining to a weapon.
 * @author Davide Cannucci
 *
 */
public class Weapon implements Serializable{

	private static final long serialVersionUID = 1L;
	private int type;
	private String name;
	private int ammo;
	private int radius;
	
	public Weapon(int weaponType){
		type = weaponType;
		
		switch(weaponType){
		
		case Constants.BAZOOKA:
			name = "Bazooka";
			ammo = Constants.BAZOOKA_AMMO;
			radius = Constants.BAZOOKA_RADIUS;
			break;
		case Constants.MINIGUN:
			name = "Minigun";
			ammo = Constants.MINIGUN_AMMO;
			radius = Constants.MINIGUN_RADIUS;
			break;
		case Constants.AIRSTRIKE:
			name = "Air Strike";
			ammo = Constants.AIRSTRIKE_AMMO;
			radius = Constants.AIRSTRIKE_RADIUS;
			break;
		case Constants.GRENADE:
			name = "Grenade";
			ammo = Constants.GRENADE_AMMO;
			radius = Constants.GRENADE_RADIUS;
			break;
		}
		
	}
	
	public int getAmmo(){
		return ammo;
	}
	
	public void addAmmo(int amount){
		ammo = ammo + amount;
	}
	
	public int getBlastRadius(){
		return radius;
	}
	
	public String getName(){
		return name;
	}
	
	public boolean hasAmmo(){
		return ammo > 0;
	}
	/**
	 * @preCondition Must have ammo
	 */
	public void use(){
		//Need to figure out something with the golf club since it has unlimited ammo
		assert(ammo>0||ammo==-1);
		//Need to insert this due to the fact that the golf club will have an ammo value of -1, representing infinite ammo
		if(ammo!=-1){
			ammo--;
		}
	}
}
